package org.reyton.dao.impl;

import org.hibernate.SessionFactory;
import org.reyton.dao.SysDepartmentDao;
import org.reyton.entity.SysDepartment;
import org.reyton.entity.SysEmployee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

/**
 * 部门表Dao实现类
 * Created by reyton on 16-12-4.
 */
@Repository("sysDepartmentDao")
public class SysDepartmentDaoImpl extends HibernateDaoSupport implements SysDepartmentDao {
    @Autowired
    @Qualifier("sessionFactory")
    public void setSuperSessionFactory(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }

    @Override
    public SysDepartment findByEmp(SysEmployee sysEmployee) {
        return (SysDepartment)this.getHibernateTemplate().find("from SysDepartment where SysDepartment = ?",sysEmployee.getSysDepartment()).get(0);
    }
}
